/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;

import javax.faces.model.SelectItem;
import queenb.net.entitybean.N850;

import queenb.web.controller.QueenbController;
import queenb.web.crm.inteface.N850Inf;
import queenb.web.crm.store.N850Store;
import queenb.web.util.ComboboxUtil;

/**
 *
 * @author Nguyen Hung
 */
public class N850Controller extends QueenbController {

    private N850Inf n850Inf;
    private int pn850;
    private String nv852;//Ten
    private String nv851;// viet tat
    private N850Store n850Store;
    private int pn100;
    private int pn450;
    private List<N850> listN850i;

    public N850Controller() {
        n850Store =new N850Store();
        Object objPn100 = getRequest().getParameter("pn100");
        if(objPn100 != null){
            pn100 = Integer.parseInt(objPn100.toString());
        }
        Object objfn450 = getRequest().getParameter("n450");
        if(objfn450 != null){
            pn450 = Integer.parseInt(objfn450.toString());
            System.out.println("-------ABC-----" + pn450);
        }
        Object object = getRequest().getParameter("action");
        if(object != null){
           listN850i = getListN850ofN450();
        }
    }

    public List<SelectItem> getSelectedN850Comb() {


            List<SelectItem> selectItemN850 = new ArrayList<SelectItem>();
            ComboboxUtil util = new  ComboboxUtil();
            selectItemN850 = util.getSelectedN850Comb();
            return selectItemN850;



    }
    
     public List<N850> getListN850ofN450(){
          List<N850> listComb850 = n850Store.findAllN850ForCombo(getLogin().getModule(), 99,this.pn450, getLogin().getUserName());
          return listComb850;
    }
    
    public List<N850> getListN850(){
          List<N850> listComb850 = n850Store.findAllN850ForCombo(getLogin().getModule(), 99,0, getLogin().getUserName());
          return listComb850;
    }

//    public List<N850> getListN850() {
//        try {
//            List<N850> listComb850 = n850Inf.findAllN850ForCombo(getLogin().getModule(), 99, getLogin().getUserName());
//            Iterator ic = listComb850.iterator();
//            while (ic.hasNext()) {
//                N850 n850 = (N850) ic.next();
//                this.nv852 = n850.getNv852();
//                this.nv851 = n850.getNv851();
//            }
//
//
//            return listComb850;
//
//        } catch (Exception ex) {
//            return null;
//        }
//    }
//    
//    public int deleteN850(int id)
//    {
//        n850Store = new N850Store();
//        if(id != 0)
//        {
//            int rows = 0;
//            rows = n850Store.deleteN850(id, getLogin().getUserName());
//            return rows;
//        }else
//        {
//            return 0;
//        }
//    }

    /**
     * @return the n850Inf
     */
    public N850Inf getN850Inf() {
        return n850Inf;
    }

    /**
     * @param n850Inf the n850Inf to set
     */
    public void setN850Inf(N850Inf n850Inf) {
        this.n850Inf = n850Inf;
    }

    /**
     * @return the pn850
     */
    public int getPn850() {
        return pn850;
    }

    /**
     * @param pn850 the pn850 to set
     */
    public void setPn850(int pn850) {
        this.pn850 = pn850;
    }

    /**
     * @return the nv852
     */
    public String getNv852() {
        return nv852;
    }

    /**
     * @param nv852 the nv852 to set
     */
    public void setNv852(String nv852) {
        this.nv852 = nv852;
    }

    /**
     * @return the nv851
     */
    public String getNv851() {
        return nv851;
    }

    /**
     * @param nv851 the nv851 to set
     */
    public void setNv851(String nv851) {
        this.nv851 = nv851;
    }

    /**
     * @return the pn100
     */
    public int getPn100() {
        return pn100;
    }

    /**
     * @param pn100 the pn100 to set
     */
    public void setPn100(int pn100) {
        this.pn100 = pn100;
    }

    /**
     * @return the pn450
     */
    public int getPn450() {
        return pn450;
    }

    /**
     * @param pn450 the pn450 to set
     */
    public void setPn450(int pn450) {
        this.pn450 = pn450;
    }
    /**
     * @return the listN850i
     */
    public List<N850> getListN850i() {
        return listN850i;
    }

    /**
     * @param listN850i the listN850i to set
     */
    public void setListN850i(List<N850> listN850i) {
        this.listN850i = listN850i;
    }
}
